use of org.orcid.jaxb.model.v3.dev1.common.Visibility in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method getVisibilityTypeElement.
private VisibilityType getVisibilityTypeElement(Visibility v) {
EducationSummary s = new EducationSummary();
s.setVisibility(v);
return s;
}
use of org.orcid.jaxb.model.v3.dev1.common.Visibility in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method getMemberships.
private Memberships getMemberships(Visibility... vs) {
Memberships e = new Memberships();
for (Visibility v : vs) {
MembershipSummary s = new MembershipSummary();
s.setVisibility(v);
e.getSummaries().add(s);
}
return e;
}
use of org.orcid.jaxb.model.v3.dev1.common.Visibility in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method getPersonalDetailsElement.
private PersonalDetails getPersonalDetailsElement(Visibility nameVisibility, Visibility bioVisiblity, Visibility otherNamesVisibility) {
PersonalDetails p = new PersonalDetails();
Name name = new Name();
name.setVisibility(nameVisibility);
p.setName(name);
Biography bio = new Biography();
bio.setVisibility(bioVisiblity);
bio.setContent("Bio test");
p.setBiography(bio);
p.setOtherNames(getOtherNamesElement(otherNamesVisibility));
return p;
}
use of org.orcid.jaxb.model.v3.dev1.common.Visibility in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method getPersonExternalIdentifiersElement.
private PersonExternalIdentifiers getPersonExternalIdentifiersElement(Visibility... vs) {
PersonExternalIdentifiers elements = new PersonExternalIdentifiers();
for (Visibility v : vs) {
PersonExternalIdentifier element = new PersonExternalIdentifier();
element.setVisibility(v);
if (elements.getExternalIdentifiers() == null) {
elements.setExternalIdentifiers(new ArrayList<PersonExternalIdentifier>());
}
elements.getExternalIdentifiers().add(element);
}
return elements;
}
use of org.orcid.jaxb.model.v3.dev1.common.Visibility in project ORCID-Source by ORCID.
the class ActivityValidator method validateFunding.
public void validateFunding(Funding funding, SourceEntity sourceEntity, boolean createFlag, boolean isApiRequest, Visibility originalVisibility) {
FundingTitle title = funding.getTitle();
if (title == null || title.getTitle() == null || StringUtils.isEmpty(title.getTitle().getContent())) {
throw new ActivityTitleValidationException();
}
// translated title language code
if (title != null && title.getTranslatedTitle() != null && !PojoUtil.isEmpty(title.getTranslatedTitle().getContent())) {
// If translated title language code is null or invalid
if (PojoUtil.isEmpty(title.getTranslatedTitle().getLanguageCode()) || !Arrays.stream(SiteConstants.AVAILABLE_ISO_LANGUAGES).anyMatch(title.getTranslatedTitle().getLanguageCode()::equals)) {
Map<String, String> params = new HashMap<String, String>();
String values = Arrays.stream(SiteConstants.AVAILABLE_ISO_LANGUAGES).collect(Collectors.joining(", "));
params.put("type", "translated title -> language code");
params.put("values", values);
throw new ActivityTypeValidationException(params);
}
}
if (isApiRequest) {
if (funding.getExternalIdentifiers() == null || funding.getExternalIdentifiers().getExternalIdentifier() == null || funding.getExternalIdentifiers().getExternalIdentifier().isEmpty()) {
throw new ActivityIdentifierValidationException();
}
}
if (funding.getAmount() != null) {
Amount amount = funding.getAmount();
if (PojoUtil.isEmpty(amount.getCurrencyCode()) && !PojoUtil.isEmpty(amount.getContent())) {
throw new OrcidValidationException("Please specify a currency code");
} else if (!PojoUtil.isEmpty(amount.getCurrencyCode()) && PojoUtil.isEmpty(amount.getContent())) {
throw new OrcidValidationException("Please specify an amount or remove the amount tag");
}
}
if (funding.getPutCode() != null && createFlag) {
Map<String, String> params = new HashMap<String, String>();
if (sourceEntity != null) {
params.put("clientName", sourceEntity.getSourceName());
}
throw new InvalidPutCodeException(params);
}
if (isApiRequest) {
validateDisambiguatedOrg(funding);
}
// Check that we are not changing the visibility
if (isApiRequest && !createFlag) {
Visibility updatedVisibility = funding.getVisibility();
validateVisibilityDoesntChange(updatedVisibility, originalVisibility);
}
externalIDValidator.validateFunding(funding.getExternalIdentifiers());
}
Aggregations