Support or ignore time zones in Scaffolding REST API

Scaffolding's GET method returns time zone information in date-data fields, for example:
{

"macro": "date-data",

"name": "s_datum_od",

"value": "2021-06-01 00:00:00 CEST"

},


but if you want to upload the same data with the PUT method, Confluence throws 500 error and logs following:

2021-11-15 10:17:14,992 ERROR [http-nio-8090-exec-6] [plugin.scaffolding.api.ScaffoldApiServiceImpl] importData Failed to update field.

-- url: /rest/scaffolding/1.0/api/form/338133081 | traceId: 3c22399a279970b0 | userName: msladek

java.lang.IllegalArgumentException: Date for "s_datum_od" is invalid date value(2021-06-01 00:00:00 CEST).

at net.customware.confluence.plugin.scaffolding.api.processor.fields.DateDataProcessor.process(DateDataProcessor.java:73)

at net.customware.confluence.plugin.scaffolding.api.processor.fields.DateDataProcessor.process(DateDataProcessor.java:24)

at net.customware.confluence.plugin.scaffolding.api.ScaffoldApiManagerImpl.processData(ScaffoldApiManagerImpl.java:101)

at net.customware.confluence.plugin.scaffolding.api.ScaffoldApiManagerImpl.handleFieldData(ScaffoldApiManagerImpl.java:54)

at net.customware.confluence.plugin.scaffolding.api.ScaffoldApiServiceImpl.processMacroArray(ScaffoldApiServiceImpl.java:216)

at net.customware.confluence.plugin.scaffolding.api.processor.fields.LoopingDataProcessor.process(LoopingDataProcessor.java:52)

at net.customware.confluence.plugin.scaffolding.api.processor.fields.LoopingDataProcessor.process(LoopingDataProcessor.java:20)

at net.customware.confluence.plugin.scaffolding.api.ScaffoldApiManagerImpl.processData(ScaffoldApiManagerImpl.java:101)

at net.customware.confluence.plugin.scaffolding.api.ScaffoldApiManagerImpl.handleFieldData(ScaffoldApiManagerImpl.java:54)

at net.customware.confluence.plugin.scaffolding.api.ScaffoldApiServiceImpl.importData(ScaffoldApiServiceImpl.java:186)

at net.customware.confluence.plugin.scaffolding.api.ScaffoldApiResource.importData(ScaffoldApiResource.java:109)

...


I think it would be appropriate to return the data in the same format that is suitable for uploading them.


Right now, I am developing an application that works with Scaffolding tables. It reads table rows for the current year and appends new rows for the next year. Because of the Scaffolding's inconsistency in handling of date-data fields I will be forced to strip time zone from all date-data values (both current and new) before uploading them back to server. It also complicates the creation of undo function that will allow users to revert back all changes made by the program. It is easy to store current data into .json file, but I can't upload them back before I strip time zones in all date-data values.


Suggested solutions:
a) optional parameter in GET request could allow getting all data without time zones

b) support time zones in PUT request (best but probably the most difficult to implement)

c) automatically strip all time zones received in PUT request and suppose that all date-data values correspond with time zone of the authenticated API user


Best regards


Michal



  • Guest
  • Nov 15 2021
  • Needs review
Hosting platform Server
  • Attach files
  • +2