@Operation(
path = "/getUserDetails",
type = Operation.MethodType.GET,
summary = "Get user details",
description = "Get user details via username, else get current user."
)
@Responses({
@Response(responseCode = 200, description = "Success", definition = "User"),
@Response(responseCode = 404, description = "User data not found", definition = "ApiResponse")
})
public ApiResponse getUserDetails(
@Param(value = "username", required = false, description = "Username of user.") String username) {
ExtDirectoryManager dm = (ExtDirectoryManager) AppUtil.getApplicationContext().getBean("directoryManager");
User user = dm.getUserByUsername(username);
WorkflowUserManager wum = (WorkflowUserManager) AppUtil.getApplicationContext().getBean("workflowUserManager");
User currentUser = wum.getCurrentUser();
if (user != null) {
return new ApiResponse(200, user, getFields());
} else if (user == null && currentUser != null) {
return new ApiResponse(200, currentUser, getFields());
} else {
return new ApiResponse(404, AppPluginUtil.getMessage("BasicCurrentUserAPI.resp.404", getClassName(), getResourceBundlePath()));
}
} |