Hello, Why it is not possible to set a lastModifiedBy in a POIXMLProperties.CoreProperties ? (Even the function exists in PackagePropertiesPart.setLastModifiedByProperty ...) I think we have to add the attribut in POIXMLProperties.CoreProperties : public String getLastModifiedBy () { return part.getLastModifiedBy; } public String setLastModifiedBy (String lastModifiedBy) { return part.setLastModifiedBy(lastModifiedBy); } Thanks,
Any chance you could turn this into a very small patch, then write a short junit unit test that verifies we can read / change / save / read this property? (It can probably re-use an existing test file for this)
Created attachment 34025 [details] patch and small test Please apply this patch to 3.15 version. It simply adds setter and getter for lastModifiedBy. Test with core properties has been updated.
Created attachment 34026 [details] moved tests to separate method
Comment on attachment 34026 [details] moved tests to separate method >Index: src/ooxml/java/org/apache/poi/POIXMLProperties.java >=================================================================== >--- src/ooxml/java/org/apache/poi/POIXMLProperties.java (revision 1751911) >+++ src/ooxml/java/org/apache/poi/POIXMLProperties.java (working copy) >@@ -301,6 +301,12 @@ > public void setLastPrinted(String date) { > part.setLastPrintedProperty(date); > } >+ public String getLastModifiedBy() { >+ return part.getLastModifiedByProperty().getValue(); >+ } >+ public void setLastModifiedBy(String lastModifiedBy) { >+ part.setLastModifiedByProperty(lastModifiedBy); >+ } > public Date getModified() { > return part.getModifiedProperty().getValue(); > } >Index: src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java >=================================================================== >--- src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java (revision 1751911) >+++ src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java (working copy) >@@ -192,7 +192,7 @@ > > XWPFDocument doc2 = XWPFTestDataSamples.writeOutAndReadBack(doc); > doc.close(); >- cp = doc.getProperties().getCoreProperties(); >+ cp = doc2.getProperties().getCoreProperties(); > Date dt3 = cp.getCreated(); > assertEquals(dateCreated, dt3); > doc2.close(); >@@ -208,6 +208,14 @@ > assertEquals("20", _coreProperties.getRevision()); > } > >+ @Test >+ public void testLastModifiedByProperty() { >+ String lastModifiedBy = _coreProperties.getLastModifiedBy(); >+ assertEquals("Paolo Mottadelli", lastModifiedBy); >+ _coreProperties.setLastModifiedBy("Test User"); >+ assertEquals("Test User", _coreProperties.getLastModifiedBy()); >+ } >+ > public static boolean dateTimeEqualToUTCString(Date dateTime, String utcString) { > Calendar utcCalendar = LocaleUtil.getLocaleCalendar(LocaleUtil.TIMEZONE_UTC); > utcCalendar.setTimeInMillis(dateTime.getTime());
Applied in r1751948, r1751949, and r1751950. Will be included in POI 3.15 beta 3 release. Updated changelog in r1751952.
I renamed these new methods to getLastModifiedByUser and setLastModifiedByUser for clarity.