Skip to content

Commit

Permalink
Deactivated records should get 409 on GET requests
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Feb 27, 2024
1 parent 26632d9 commit 3279481
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public Response toResponse(Throwable t) {
logShortError(t, clientId);
} else if (t instanceof LockedException) {
logShortError(t, clientId);
} else if (t instanceof DeactivatedException) {
logShortError(t, clientId);
} else if (t instanceof ClientDeactivatedException) {
logShortError(t, clientId);
} else if (t instanceof OrcidNonPublicElementException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1642,16 +1642,8 @@ public Response deleteResearchResource(String orcid, Long putCode) {
return Response.noContent().build();
}

private void checkProfileStatus(String orcid, boolean readOperation) {
try {
orcidSecurityManager.checkProfile(orcid);
} catch (DeactivatedException e) {
// If it is a read operation, ignore the deactivated status since we
// are going to return the empty element with the deactivation date
if (!readOperation) {
throw e;
}
}
private void checkProfileStatus(String orcid, boolean readOperation) throws DeactivatedException {
orcidSecurityManager.checkProfile(orcid);
}

private Map<String, String> addParmsMismatchedPutCode(Long urlPutCode, Long bodyPutCode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ public void checkProfile(String orcid) throws NoResultException, OrcidDeprecated

// Check if the user record is locked
if (!profile.isAccountNonLocked()) {
LockedException lockedException = new LockedException();
LockedException lockedException = new LockedException(orcid + " is locked");
lockedException.setOrcid(profile.getId());
throw lockedException;
}

// Check if the user record is deactivated
if (profile.getDeactivationDate() != null) {
DeactivatedException exception = new DeactivatedException();
exception.setOrcid(orcid);
DeactivatedException exception = new DeactivatedException(orcid + " is deactivated");
exception.setOrcid(orcid);
throw exception;
}
}
Expand Down

0 comments on commit 3279481

Please sign in to comment.