|
55 | 55 | import org.orcid.pojo.grouping.WorkGroupingSuggestion; |
56 | 56 | import org.orcid.pojo.grouping.WorkGroupingSuggestions; |
57 | 57 | import org.orcid.pojo.grouping.WorkGroupingSuggestionsCount; |
| 58 | +import org.slf4j.Logger; |
| 59 | +import org.slf4j.LoggerFactory; |
58 | 60 | import org.springframework.beans.factory.annotation.Value; |
59 | 61 | import org.springframework.stereotype.Controller; |
60 | 62 | import org.springframework.web.bind.annotation.PathVariable; |
|
71 | 73 | @RequestMapping(value = { "/works" }) |
72 | 74 | public class WorksController extends BaseWorkspaceController { |
73 | 75 |
|
| 76 | + private static final Logger LOGGER = LoggerFactory.getLogger(WorksController.class); |
| 77 | + |
74 | 78 | private static final Pattern LANGUAGE_CODE = Pattern.compile("([a-zA-Z]{2})(_[a-zA-Z]{2}){0,2}"); |
75 | 79 | private static final String PAGE_SIZE_DEFAULT = "50"; |
76 | 80 |
|
@@ -534,21 +538,30 @@ private void initializePublicationDate(WorkForm w) { |
534 | 538 | } |
535 | 539 |
|
536 | 540 | return null; |
537 | | - } |
| 541 | + } |
| 542 | + |
538 | 543 | /** |
539 | 544 | * Creates a new work |
540 | 545 | * |
541 | 546 | * @throws Exception |
542 | 547 | */ |
543 | 548 | @RequestMapping(value = "/work.json", method = RequestMethod.POST) |
544 | | - public @ResponseBody WorkForm postWork(HttpServletRequest request, @RequestBody WorkForm workForm) throws Exception { |
| 549 | + public @ResponseBody WorkForm postWork(HttpServletRequest request, @RequestBody WorkForm workForm, |
| 550 | + @RequestParam(value = "isBibtex", required = false, defaultValue = "false") Boolean isBibtex) throws Exception { |
545 | 551 | validateWork(workForm); |
546 | 552 | if (workForm.getErrors().size() == 0) { |
547 | 553 | removeEmptyExternalIdentifiers(workForm); |
548 | 554 | if (isRecordHolderNotInContributors(workForm)) { |
549 | | - List<String> errors = workForm.getErrors(); |
550 | | - errors.add(getMessage("web.orcid.record_holder_not_contributor.exception")); |
551 | | - return workForm; |
| 555 | + if (Boolean.TRUE.equals(isBibtex)) { |
| 556 | + // For now, if the request comes from bibtex, we just need |
| 557 | + // to ignore the record owner, we can't validate if it is |
| 558 | + // already in one of the provided contributors |
| 559 | + } else { |
| 560 | + LOGGER.error("Record owner is not in contributors list, orcid id: " + getCurrentUserOrcid()); |
| 561 | + List<String> errors = workForm.getErrors(); |
| 562 | + errors.add(getMessage("web.orcid.record_holder_not_contributor.exception")); |
| 563 | + return workForm; |
| 564 | + } |
552 | 565 | } |
553 | 566 | if (workForm.getPutCode() != null) |
554 | 567 | updateWork(workForm); |
|
0 commit comments