use of org.orcid.jaxb.model.common_rc1.Visibility in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method getEducations.
private Educations getEducations(Visibility... vs) {
Educations e = new Educations();
for (Visibility v : vs) {
EducationSummary s = new EducationSummary();
s.setVisibility(v);
e.getSummaries().add(s);
}
return e;
}
use of org.orcid.jaxb.model.common_rc1.Visibility in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method getOtherNamesElement.
private OtherNames getOtherNamesElement(Visibility... vs) {
OtherNames otherNames = new OtherNames();
for (Visibility v : vs) {
OtherName o = new OtherName();
o.setVisibility(v);
if (otherNames.getOtherNames() == null) {
otherNames.setOtherNames(new ArrayList<OtherName>());
}
otherNames.getOtherNames().add(o);
}
return otherNames;
}
use of org.orcid.jaxb.model.common_rc1.Visibility in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method getWorks.
private Works getWorks(Visibility... vs) {
Works works = new Works();
for (Visibility v : vs) {
WorkGroup g = new WorkGroup();
WorkSummary s = new WorkSummary();
s.setVisibility(v);
g.getWorkSummary().add(s);
works.getWorkGroup().add(g);
}
return works;
}
use of org.orcid.jaxb.model.common_rc1.Visibility in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method getResearcherUrlsElement.
private ResearcherUrls getResearcherUrlsElement(Visibility... vs) {
ResearcherUrls elements = new ResearcherUrls();
for (Visibility v : vs) {
ResearcherUrl element = new ResearcherUrl();
element.setVisibility(v);
if (elements.getResearcherUrls() == null) {
elements.setResearcherUrls(new ArrayList<ResearcherUrl>());
}
elements.getResearcherUrls().add(element);
}
return elements;
}
use of org.orcid.jaxb.model.common_rc1.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);
}
// Check that we are not changing the visibility
if (isApiRequest && !createFlag) {
Visibility updatedVisibility = funding.getVisibility();
validateVisibilityDoesntChange(updatedVisibility, originalVisibility);
}
externalIDValidator.validateFunding(funding.getExternalIdentifiers());
}
Aggregations