/** * Gets the base username to use to determine a user's workspace. This is not used directly as a path segment, but * forms the sole basis for it. * * @since 9.2 */ protected String getUserName(NuxeoPrincipal principal, String username) { if (principal != null) { username = principal.getActingUser(); } if (NuxeoPrincipal.isTransientUsername(username)) { // no personal workspace for transient users username = null; } if (StringUtils.isEmpty(username)) { username = null; } return username; }
protected void validateParameters() { if (user == null && (users == null || users.isEmpty()) && email == null) { throw new IllegalParameterException("'users' or 'email' parameters must be set"); } else if (email != null && end == null) { throw new IllegalParameterException("'end' parameter must be set when adding a permission for an 'email'"); } ensureUserListIsUsed(); ConfigurationService configService = Framework.getService(ConfigurationService.class); if (configService.isBooleanPropertyFalse(ALLOW_VIRTUAL_USER)) { UserManager userManager = Framework.getService(UserManager.class); List<String> unknownNames = users.stream() .filter(userOrGroupName -> !isTransientUsername(userOrGroupName) && userManager.getUserModel(userOrGroupName) == null && userManager.getGroupModel(userOrGroupName) == null) .collect(toList()); if (!unknownNames.isEmpty()) { String errorMsg = String.format( "The following set of User or Group names do not exist: [%s]. Please provide valid ones.", String.join(",", unknownNames)); throw new IllegalParameterException(errorMsg); } } }