-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closes #2540 & #2614 #2615
Closes #2540 & #2614 #2615
Conversation
9030d40
to
4be2290
Compare
…e_URL' of https://github.com/CeON/dataverse into 2540_Create_double_blind_review_ready_Anonymized_Private_URL
@@ -178,7 +185,8 @@ public DatasetPage(DataverseSession session, EjbDataverseEngine commandEngine, | |||
DatasetThumbnailService datasetThumbnailService, DatasetSummaryService datasetSummaryService, | |||
GuestbookResponseServiceBean guestbookResponseService, ConfirmEmailServiceBean confirmEmailService, | |||
AuthenticationServiceBean authenticationService, DatasetPageFacade datasetPageFacade, | |||
CitationFactory citationFactory, UningestInfoService uningestInfoService) { | |||
CitationFactory citationFactory, UningestInfoService uningestInfoService, | |||
SettingsWrapper settingsWrapper) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added but not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@JoinColumn(nullable = false) | ||
private DvObject definitionPoint; | ||
|
||
@Column(nullable = true) | ||
private String privateUrlToken; | ||
|
||
private boolean anonymized; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this new column also be considered in equals
/toString
below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
this.displayCitation = displayCitation; | ||
|
||
public boolean displayCitation() { | ||
return ! this.session.isViewedFromAnonymizedPrivateUrl(this.dataset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You added DatasetPage.isViewedFromAnonymizedPrivateUrl
but didn't use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i did in metadataTab.xhtml
<ui:param name="isViewedFromAnonymizedPrivateUrl" value="#{DatasetPage.isViewedFromAnonymizedPrivateUrl()}"/>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I know, just thought it could also be used here and in the method below as well. But not insisting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
boolean isAnonymized(); | ||
|
||
boolean isAffiliatedWith(DvObject object); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The isAffiliatedWith
name is a bit misleading. In dataverse affiliation
is usually used between users and organizations. Not sure actually if it's worth having this method for all users, it seems to make sense only for PrivateUrlUser
, so maybe we could just have it there (same for isAnonymized
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having these methods in User class hierarchy simplifies client code and is more elegant than using instanceof operator (my opintion, you may disagree)
isAffiliatedWith - so maybe "isRelatedWith" or isAllowedToView ? (any proposals) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having these methods in User class hierarchy simplifies client code and is more elegant than using instanceof operator (my opintion, you may disagree)
Would agree that instanceof
is usually a sign of sub-optimal design. But adding methods to an interface which will only be used for a specific implementation does also violate the interface segregation principle. And it looks like that's the case here as the only place we use those two new methods are for instances of PrivateUrlUser
:
public boolean isViewedFromPrivateUrl(final DvObject dataset) {
return getUser() instanceof PrivateUrlUser && getUser().isAffiliatedWith(dataset);
}
public boolean isViewedFromAnonymizedPrivateUrl(final DvObject dataset) {
return getUser().isAnonymized() && isViewedFromPrivateUrl(dataset);
}
By that I mean, the above methods specifically have ...PrivateUrl(..
in their name, so we're not concerned about any other types of users.
isAffiliatedWith - so maybe "isRelatedWith" or isAllowedToView ? (any proposals) ?
If we're accepting that we're in the context of PrivateUrlUser
, then I would say you don't need that method at all and could just do:
public boolean isViewedFromPrivateUrl(final DvObject dataset) {
return getPrivateUrlUser().exists(u -> u.getDatasetId() == dataset.getId());
}
public boolean isViewedFromAnonymizedPrivateUrl(final DvObject dataset) {
return getPrivateUrlUser().exists(PrivateUrlUser::isAnonymized) && isViewedFromPrivateUrl(dataset);
}
private Option<PrivateUrlUser> getPrivateUrlUser() {
return Option.of(getUser()).filter(PrivateUrlUser.class::isInstance).map(PrivateUrlUser.class::cast);
}
Just a proposition. If you want to keep the method in PrivateUrlUser
, then isAllowedToView
would be fine, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I'm aware that I have conflicting situation here - striving for encapsulation and genericness naturally violates interface segregation principle (eg. Object.hashCode violates it) - it is a contentious issue
I renamed isAffiliatedWith into isAllowedToView and changed Guest.isAllowedToView to return true as this makes more sense (though Guest.isAllowedToView implementation is not used in any usecase)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I'm aware that I have conflicting situation here - striving for encapsulation and genericness naturally violates interface segregation principle (eg. Object.hashCode violates it) - it is a contentious issue
So let's change it, and remove those methods from User
. Genericness is not giving us anything here, as we don't even make reasonable use of it right from the start.
I agreed on isAllowedToView
name only under the condition that it's for PrivateUrlUser
only. For other implementations of User
the method (at least with the current implementation) doesn't make much sense. It's not like someone who calls user.isAllowedToView(dataset)
would get a correct response which would account for access permissions.
No description provided.