Skip to content

fix npes on template page#8917

Merged
kcondon merged 2 commits intoIQSS:developfrom
GlobalDataverseCommunityConsortium:GDCC/8916-fix_template_npe
Aug 12, 2022
Merged

fix npes on template page#8917
kcondon merged 2 commits intoIQSS:developfrom
GlobalDataverseCommunityConsortium:GDCC/8916-fix_template_npe

Conversation

@qqmyers
Copy link
Member

@qqmyers qqmyers commented Aug 12, 2022

What this PR does / why we need it: Fixes NPEs introduced in #8902

Which issue(s) this PR closes:

Closes #8916

Special notes for your reviewer: After some investigation, it appears that two of the calls replaced with DatasetPage.hasRestrictedFiles in #8902 were 'working' because nulls in the xhtml logic were being ignored, i.e. in dataset-license-terms.xhtml
line 251: DatasetPage.restrictedFileCount returns 0 if the workingVersion is null (true on the template page, so the count of the # of restricted files HTML is suppressed on the template page.
line 267 - same logic appears to be accidentally suppressing any terms of access in the view mode for a template page. (not fixed in this PR)
line 310 (prior to this PR): DatasetPage.dataset.editVersion.hasRestrictedFile ~worked on the template page because DatasetPage creates an empty Dataset when initializing the dataset variable and editVersion would then create a datasetversion for the empty dataset and its hasRestrictedFile method them reports false, with the net effect of appropriately suppressing the info about needed access requests or ToA.

This PR keeps the changes in #8902 and adds a check of datasetPage (a variable that is only true when this fragment is included from a dataset page) prior to DatasetPage.hasRestrictedFiles which avoids having it called from the template page. This pattern is already done elsewhere in the dataset-license-terms.xhtml file.

In working through this, I did note the line 267 issue above (terms of access set in a template are not show in the template/view mode) as well as other issues (collapse state isn't set correctly due to use of jsf:class instead of class, no display of template fileaccessrequest status) - rather than bloat this PR or potentially miss other related issues, I'll open an issue to review what should be happening in the template view and note these as an initial list.

Suggestions on how to test this: Test the scenario in #8916 as well as verifying that there is no null pointer exception when viewing a template with terms of access and/or data place terms added.

Does this PR introduce a user interface change? If mockups are available, please link/include them here: no

Is there a release notes update needed for this change?:

Additional documentation:

Copy link
Contributor

@scolapasta scolapasta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qqmyers very, vey minor - in one place you added datasetPage, and in the other "datasetPage == true". Both do the same thing, but can we keep them consistent? While I normally prefer the former, in this case, I feel the latter may be easier to read? Bit I'm fine with either.

@qqmyers qqmyers mentioned this pull request Aug 12, 2022
@qqmyers
Copy link
Member Author

qqmyers commented Aug 12, 2022

OK - I added == true above. There are still uses of both forms (with/without == true on the page).

@scolapasta scolapasta added this to the 5.12 milestone Aug 12, 2022
@kcondon kcondon self-assigned this Aug 12, 2022
@kcondon kcondon merged commit 6464c4c into IQSS:develop Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create template: Throws exception when rendering after save, is created. Happens on unreleased develop branch.

3 participants