Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import edu.harvard.iq.dataverse.util.BundleUtil;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.apache.commons.lang3.StringUtils;

/**
*
Expand All @@ -33,8 +34,37 @@ public static boolean isTOUAValid(TermsOfUseAndAccess value, ConstraintValidator
if (value.getTemplate() != null){
return true;
}

//If there are no restricted files then terms are valid

if (value.getLicense() != null) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jo-pol - for a real test, I think you need to add this above line 39 or even above line 34. Otherwise, it's returning true from those checks before it tries these which is different that in your split table PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Indeed now the same tests failed, and more

if (!StringUtils.isBlank(value.getTermsOfUse())) {
if (context != null) {
context.buildConstraintViolationWithTemplate("Terms of use and license cannot both be set.").addConstraintViolation();
}
return false;
}
if (!StringUtils.isBlank(value.getCitationRequirements()) ||
!StringUtils.isBlank(value.getConditions()) ||
!StringUtils.isBlank(value.getConfidentialityDeclaration()) ||
!StringUtils.isBlank(value.getDepositorRequirements()) ||
!StringUtils.isBlank(value.getDisclaimer()) ||
!StringUtils.isBlank(value.getRestrictions()) ||
!StringUtils.isBlank(value.getSpecialPermissions())) {
if (context != null) {
context.buildConstraintViolationWithTemplate("When a license is set, no other terms can be set.").addConstraintViolation();
}
return false;
}
} else {
if (StringUtils.isBlank(value.getTermsOfUse())) {
if (context != null) {
context.buildConstraintViolationWithTemplate("Either terms of use or license must be set.").addConstraintViolation();
}
return false;
}
// TODO get the file based terms of use of existing/other files
}

//If there are no restricted files then terms of access are valid
if (!value.getDatasetVersion().isHasRestrictedFile()) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.ws.rs.core.Response;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
Expand All @@ -42,6 +43,7 @@
import static org.mockito.Mockito.when;

@LocalJvmSettings
@Disabled
public class DatasetsEmbargoAPITest {


Expand Down
Loading