use of org.orcid.jaxb.model.record.bulk.BulkElementContainer in project ORCID-Source by ORCID.
the class MemberV2ApiServiceVersionedDelegatorImpl method createWorks.
@Override
public Response createWorks(String orcid, Object works) {
checkProfileStatus(orcid, false);
// validate works object before changing version
Map<Integer, BulkElement> errors = new HashMap<>();
if (works != null) {
BulkElementContainer workBulk = (BulkElementContainer) works;
for (int i = workBulk.getBulk().size() - 1; i >= 0; i--) {
BulkElement bulkElement = workBulk.getBulk().get(i);
try {
schemaValidator.validate(bulkElement);
} catch (WebApplicationException e) {
if (org.orcid.jaxb.model.record_rc3.Work.class.isAssignableFrom(bulkElement.getClass())) {
org.orcid.jaxb.model.error_rc3.OrcidError error = orcidCoreExceptionMapper.getOrcidErrorV2Rc3(9001, 400, e);
workBulk.getBulk().remove(i);
errors.put(i, error);
workBulk.getBulk().add(i, error);
} else if (org.orcid.jaxb.model.record_rc4.Work.class.isAssignableFrom(bulkElement.getClass())) {
org.orcid.jaxb.model.error_rc4.OrcidError error = orcidCoreExceptionMapper.getOrcidErrorV2Rc4(9001, 400, e);
workBulk.getBulk().remove(i);
errors.put(i, error);
workBulk.getBulk().add(i, error);
} else {
org.orcid.jaxb.model.error_v2.OrcidError error = orcidCoreExceptionMapper.getOrcidErrorV2(9001, 400, e);
workBulk.getBulk().remove(i);
errors.put(i, error);
workBulk.getBulk().add(i, error);
}
}
}
}
works = processObject(works);
return memberV2ApiServiceDelegator.createWorks(orcid, works);
}
Aggregations