Skip to content

Commit

Permalink
60 prod no change put request behaviour (#7001)
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

* Fixed 400 error

* replacing explicitly ${activity} with work  string
  • Loading branch information
Camelia-Orcid authored Feb 28, 2024
1 parent bcb38ed commit 91704ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,20 +355,21 @@ public Work updateWork(String orcid, Work work, boolean isApiRequest) {

Work workSaved = jpaJaxbWorkAdapter.toWork(workEntity);
WorkForm workFormSaved = WorkForm.valueOf(workSaved, maxContributorsForUI);
String devMessage = localeManager.resolveMessage("apiError.9010.developerMessage").replace("${activity}", "work");

if (workFormSaved.compare(WorkForm.valueOf(work, maxContributorsForUI))) {
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
String client = null;
if (sourceEntity.getSourceProfile() != null && sourceEntity.getSourceProfile().getId() != null) {
client = sourceEntity.getSourceProfile().getId();
if(!StringUtils.equals(client, orcid) ) {
throw new OrcidForbiddenException(localeManager.resolveMessage("apiError.9010.developerMessage","work"));
throw new OrcidForbiddenException(devMessage );
}
}
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.9010.developerMessage","work"));
throw new OrcidForbiddenException(devMessage );
}
}
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 @@ -375,9 +375,8 @@ public Work updateWork(String orcid, Work work, boolean isApiRequest) {

if (workFormSaved.compare(WorkForm.valueOf(work, maxContributorsForUI))) {
if (activeSource != null) {

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

Expand Down

0 comments on commit 91704ae

Please sign in to comment.