Skip to content

Commit

Permalink
ceate license with current user
Browse files Browse the repository at this point in the history
  • Loading branch information
Paurikova2 committed Oct 22, 2024
1 parent 6ad77f8 commit 55f36a6
Showing 1 changed file with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,31 @@ public ClarinLicenseRest importLicense(HttpServletRequest request)
throw new RuntimeException("Context is null!");
}
//get param
UUID epersonUUID = UUID.fromString(request.getParameter("eperson"));
EPerson ePerson = ePersonService.find(context, epersonUUID);
String epersonParam = request.getParameter("eperson");
EPerson ePerson = null;
if (Objects.nonNull(epersonParam)) {
UUID epersonUUID = UUID.fromString(request.getParameter("eperson"));
ePerson = ePersonService.find(context, epersonUUID);
}

EPerson currUser = null;
// Set the current user to the EPerson if the EPerson was found and create the license.
if (Objects.nonNull(ePerson)) {
currUser = context.getCurrentUser();
context.setCurrentUser(ePerson);
}

//set current user to eperson and create license
EPerson currUser = context.getCurrentUser();
context.setCurrentUser(ePerson);
//turn off authorization
context.turnOffAuthorisationSystem();
ClarinLicenseRest clarinLicenseRest = clarinLicenseRestRepository.createAndReturn();
context.restoreAuthSystemState();
//set back current use
context.setCurrentUser(currUser);

// Restore the current user if one was previously set.
if (Objects.nonNull(ePerson)) {
context.setCurrentUser(currUser);
}

context.complete();
return clarinLicenseRest;
}


}

0 comments on commit 55f36a6

Please sign in to comment.