@Test public void shouldSetModificationDateAndCreationDateWhenCreationDateNotExists() { DocumentModel doc = session.createDocumentModel("/", "file", "File"); Map<String, Object> originalProperties = new HashMap<>(doc.getProperties("dublincore")); Set<String> expectedChangedProperties = new HashSet<>(); expectedChangedProperties.add("dc:created"); expectedChangedProperties.add("dc:modified"); Calendar currentDate = Calendar.getInstance(); storageService.setModificationDate(doc, currentDate); assertDocumentPropertiesChanges(doc, originalProperties, expectedChangedProperties); assertEquals(currentDate, doc.getPropertyValue("dc:created")); assertEquals(currentDate, doc.getPropertyValue("dc:modified")); }
@Override public void setModificationDate(DocumentModel doc, Calendar modificationDate) { Framework.doPrivileged(() -> { doc.setPropertyValue(DUBLINCORE_MODIFIED_DATE_PROPERTY, modificationDate); if (doc.getPropertyValue(DUBLINCORE_CREATED_DATE_PROPERTY) == null) { setCreationDate(doc, modificationDate); } }); }
DublinCoreStorageServiceImpl extends DefaultComponent implements DublinCoreStorageService { @Override public void setModificationDate(DocumentModel doc, Calendar modificationDate) { Framework.doPrivileged(() -> { doc.setPropertyValue(DUBLINCORE_MODIFIED_DATE_PROPERTY, modificationDate); if (doc.getPropertyValue(DUBLINCORE_CREATED_DATE_PROPERTY) == null) { setCreationDate(doc, modificationDate); } }); } }
DublinCoreStorageServiceImpl extends DefaultComponent implements DublinCoreStorageService { @Override public void setModificationDate(DocumentModel doc, Calendar modificationDate) { Framework.doPrivileged(() -> { doc.setPropertyValue(DUBLINCORE_MODIFIED_DATE_PROPERTY, modificationDate); if (doc.getPropertyValue(DUBLINCORE_CREATED_DATE_PROPERTY) == null) { setCreationDate(doc, modificationDate); } }); }  }
DublinCoreStorageServiceImpl extends DefaultComponent implements DublinCoreStorageService { @Override public void setModificationDate(DocumentModel doc, Calendar modificationDate) { Framework.doPrivileged(() -> { doc.setPropertyValue(DUBLINCORE_MODIFIED_DATE_PROPERTY, modificationDate); if (doc.getPropertyValue(DUBLINCORE_CREATED_DATE_PROPERTY) == null) { setCreationDate(doc, modificationDate); } }); }  @Override void setCreationDate(DocumentModel doc, Calendar creationDate); @Override void setIssuedDate(DocumentModel doc, Calendar issuedDate); @Override void setModificationDate(DocumentModel doc, Calendar modificationDate); @Override void addContributor(DocumentModel doc, Event event); }
DublinCoreStorageServiceImpl extends DefaultComponent implements DublinCoreStorageService { @Override public void setModificationDate(DocumentModel doc, Calendar modificationDate) { Framework.doPrivileged(() -> { doc.setPropertyValue(DUBLINCORE_MODIFIED_DATE_PROPERTY, modificationDate); if (doc.getPropertyValue(DUBLINCORE_CREATED_DATE_PROPERTY) == null) { setCreationDate(doc, modificationDate); } }); }  @Override void setCreationDate(DocumentModel doc, Calendar creationDate); @Override void setIssuedDate(DocumentModel doc, Calendar issuedDate); @Override void setModificationDate(DocumentModel doc, Calendar modificationDate); @Override void addContributor(DocumentModel doc, Event event);  }