Skip to content

Commit

Permalink
60 prod no change put request behaviour (#6998)
Browse files Browse the repository at this point in the history
* Added the check for put requests when the source is not the same

* Fixed the failing testcase, added testcase for update with different sources

* Attempt to fix the race issue with random token generation

* Fixed the equality check for string

* Fixed the equality check for the source entity

* Changed the developer message code
  • Loading branch information
Camelia-Orcid authored Feb 27, 2024
1 parent e523865 commit 55e0943
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,13 @@ public Work updateWork(String orcid, Work work, boolean isApiRequest) {
if (sourceEntity.getSourceProfile() != null && sourceEntity.getSourceProfile().getId() != null) {
client = sourceEntity.getSourceProfile().getId();
if(!StringUtils.equals(client, orcid) ) {
throw new OrcidForbiddenException(localeManager.resolveMessage("apiError.9014.developerMessage"));
throw new OrcidForbiddenException(localeManager.resolveMessage("apiError.9010.developerMessage","work"));
}
}
if (sourceEntity.getSourceClient() != null && sourceEntity.getSourceClient().getClientName() != null) {
client = sourceEntity.getSourceClient().getClientName();
if(!StringUtils.equals(sourceEntity.getSourceClient().getClientId(), workEntity.getClientSourceId()) ) {
throw new OrcidForbiddenException(localeManager.resolveMessage("apiError.9014.developerMessage"));
throw new OrcidForbiddenException(localeManager.resolveMessage("apiError.9010.developerMessage","work"));
}
}
LOGGER.info("There is no changes in the work with putCode " + work.getPutCode() + " send it by " + client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public Work updateWork(String orcid, Work work, boolean isApiRequest) {
if (activeSource != null) {

if(!activeSource.equals(workSaved.getSource())) {
throw new OrcidForbiddenException(localeManager.resolveMessage("apiError.9014.developerMessage"));
throw new OrcidForbiddenException(localeManager.resolveMessage("apiError.9010.developerMessage","work"));
}
}

Expand Down

0 comments on commit 55e0943

Please sign in to comment.