Upload page not displaying files
Original Problem
The Upload page for a dataset was not showing any files in the Data, Metadata or Datastore areas, just the spinning icon.
The request the page was making to Hubbub was missing a query parameter data=true
that made Hubbub return the file info data expected by the page. The javascript failed because the returned data was missing the structure it was expecting.
Subsequently, could not convert response to JsonNode because the Spring bean wiring had picked up the RestTemplate configured for the WMS that only had a Gml2WmsFeatureInfoMessageConverter
message converter. Added another normal
RestTemplate that by default has a Jackson message converter. The @Qualifier
annotations on the RestTemplates and in the components requiring them (DataciteService, HubbubService, MapViewer) ensure the Correct RestTemplate is wired in.
Even with correct RestTemplate Spring could not convert to JsonNode so made HubbubResponse POJO to handle response from Hubbub. Annotating this with @JsonCreator
and @JsonProperty
allow Jackson to automatically create these objects in RestTemplate response.
HubbubResponse makes it easier to test HubbubService can check resttemplate can convert from the json file to HubbubResponse and then make assertions about what is in there.
UploadDocument can then be created from three HubbubResponses for dropbox, datastore and supporting-documents. Taken the logic for creation out of the UploadDocumentService.
Simplified UploadDocumentService.getCsv to use streaming and filtering and fileInfo.getTruncatedPath()
Client-side
Fixed Accept header in requests due to change from consumes to produces in UploadController as the methods do produce the upload media type rather than consume them.
Reduced polling for new Hubbub data from 1 sec to 7 seconds, 1 second frequency seemed excessive.
Other Work
Uploader Controller formatting and tidying
- Removing unused parameters, mainly CatalogueUser.
- Adding
@PreAuthorize("@permission.userCanUpload(#id)")
to secure endpoints rather thanuserCanUpload(id)
method -
@RequestMapping
to@PostMapping
or@PutMapping
to make it clearer. - Alignment of method parameters to make it clearer.
Deleted classes
- .../upload/Checksum.java is unused
- .../upload/UploadDocumentPagination.java, UploadFile and UploadFiles moved into HubbubResponse or UploadDocument.
- UploadType unused
Logging
logback.xml checks for changes in configuration every 3 minutes. Should allow us to change the logging levels of a running application if needed.
NullPointerException in MetadataQualityService
Handled NullPointerException in MetadataQualityService if description is missing and report it as an error.