use of org.orcid.core.exception.OrcidNonPublicElementException in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method checkIsPublicNameTest.
@Test
public void checkIsPublicNameTest() {
Name n = new Name();
n.setVisibility(Visibility.PUBLIC);
publicAPISecurityManagerV2.checkIsPublic(n);
try {
n.setVisibility(Visibility.LIMITED);
publicAPISecurityManagerV2.checkIsPublic(n);
fail();
} catch (OrcidNonPublicElementException e) {
}
try {
n.setVisibility(Visibility.PRIVATE);
publicAPISecurityManagerV2.checkIsPublic(n);
fail();
} catch (OrcidNonPublicElementException e) {
}
}
use of org.orcid.core.exception.OrcidNonPublicElementException in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method checkIsPublicBiographyTest.
@Test
public void checkIsPublicBiographyTest() {
Biography b = new Biography();
b.setVisibility(Visibility.PUBLIC);
b.setContent("Bio test");
publicAPISecurityManagerV2.checkIsPublic(b);
try {
b.setVisibility(Visibility.LIMITED);
publicAPISecurityManagerV2.checkIsPublic(b);
fail();
} catch (OrcidNonPublicElementException e) {
}
try {
b.setVisibility(Visibility.PRIVATE);
publicAPISecurityManagerV2.checkIsPublic(b);
fail();
} catch (OrcidNonPublicElementException e) {
}
}
use of org.orcid.core.exception.OrcidNonPublicElementException in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Impl method filter.
@Override
public void filter(Person person) {
if (person == null) {
return;
}
if (person.getAddresses() != null) {
filter(person.getAddresses());
}
if (person.getEmails() != null) {
filter(person.getEmails());
}
if (person.getExternalIdentifiers() != null) {
filter(person.getExternalIdentifiers());
}
if (person.getKeywords() != null) {
filter(person.getKeywords());
}
if (person.getOtherNames() != null) {
filter(person.getOtherNames());
}
if (person.getResearcherUrls() != null) {
filter(person.getResearcherUrls());
}
Name name = person.getName();
if (name != null) {
try {
checkIsPublic(name);
} catch (OrcidNonPublicElementException ex) {
person.setName(null);
}
}
Biography bio = person.getBiography();
if (bio != null) {
try {
checkIsPublic(bio);
} catch (OrcidNonPublicElementException ex) {
person.setBiography(null);
}
}
}
use of org.orcid.core.exception.OrcidNonPublicElementException in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Impl method filter.
@Override
public void filter(WorkBulk workBulk) {
if (workBulk != null && workBulk.getBulk() != null) {
List<BulkElement> filtered = new ArrayList<>();
for (int i = 0; i < workBulk.getBulk().size(); i++) {
BulkElement bulkElement = workBulk.getBulk().get(i);
if (bulkElement instanceof OrcidError) {
filtered.add(bulkElement);
} else {
try {
checkIsPublic((Work) bulkElement);
filtered.add(bulkElement);
} catch (OrcidNonPublicElementException e) {
filtered.add(orcidCoreExceptionMapper.getOrcidError(e));
}
}
}
workBulk.setBulk(filtered);
}
}
Aggregations