use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class UserService method addUserAuthorities.
@Override
public List<UserAuthorityDto> addUserAuthorities(String username, UserAuthoritiesRequest request) {
try {
List<UserAuthorityDto> authorizations = new ArrayList<>();
final UserDetails user = this.getUserManager().getUser(username);
;
request.forEach(authorization -> {
try {
if (!this.getAuthorizationManager().isAuthOnGroupAndRole(user, authorization.getGroup(), authorization.getRole(), true)) {
this.getAuthorizationManager().addUserAuthorization(username, authorization.getGroup(), authorization.getRole());
}
} catch (ApsSystemException ex) {
logger.error("Error in add authorities for {}", username, ex);
throw new RestServerError("Error in add authorities", ex);
}
authorizations.add(new UserAuthorityDto(authorization.getGroup(), authorization.getRole()));
});
return authorizations;
} catch (ApsSystemException ex) {
logger.error("Error in add authorities for {}", username, ex);
throw new RestServerError("Error in add authorities", ex);
}
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class UserService method addUser.
@Override
public UserDto addUser(UserRequest userRequest) {
try {
UserDetails newUser = this.createUser(userRequest);
this.getUserManager().addUser(newUser);
return dtoBuilder.convert(newUser);
} catch (ApsSystemException e) {
logger.error("Error in adding user {}", userRequest.getUsername(), e);
throw new RestServerError("Error in adding user", e);
}
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class WidgetService method addWidget.
@Override
public WidgetDto addWidget(WidgetRequest widgetRequest) {
WidgetType widgetType = new WidgetType();
this.processWidgetType(widgetType, widgetRequest);
WidgetType oldWidgetType = this.getWidgetManager().getWidgetType(widgetType.getCode());
BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(widgetType, "widget");
if (null != oldWidgetType) {
bindingResult.reject(WidgetValidator.ERRCODE_WIDGET_ALREADY_EXISTS, new String[] { widgetType.getCode() }, "widgettype.exists");
throw new ValidationGenericException(bindingResult);
} else if (null == this.getGroupManager().getGroup(widgetRequest.getGroup())) {
bindingResult.reject(WidgetValidator.ERRCODE_WIDGET_GROUP_INVALID, new String[] { widgetRequest.getGroup() }, "widgettype.group.invalid");
throw new ValidationGenericException(bindingResult);
}
WidgetDto widgetDto = null;
try {
this.getWidgetManager().addWidgetType(widgetType);
this.createAndAddFragment(widgetType, widgetRequest);
widgetDto = this.dtoBuilder.convert(widgetType);
this.addFragments(widgetDto);
} catch (Exception e) {
logger.error("Failed to add widget type for request {} ", widgetRequest);
throw new RestServerError("error in add widget", e);
}
return widgetDto;
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class AuthorizationService method getRoleUtilizer.
@Override
public List<UserDto> getRoleUtilizer(String roleCode) {
try {
List<String> usernames = this.getAuthorizationManager().getUsersByRole(roleCode, false);
List<UserDto> dtoList = new ArrayList<>();
if (null != usernames) {
usernames.stream().forEach(i -> {
try {
dtoList.add(this.getDtoBuilder().convert(this.getUserManager().getUser(i)));
} catch (ApsSystemException e) {
logger.error("error loading {}", i, e);
}
});
}
return dtoList;
} catch (ApsSystemException ex) {
logger.error("Error loading user references for role {}", roleCode, ex);
throw new RestServerError("Error loading user references by role", ex);
}
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class AuthorizationService method getGroupUtilizer.
@Override
public List<UserDto> getGroupUtilizer(String groupCode) {
try {
List<String> usernames = ((GroupUtilizer<String>) this.getAuthorizationManager()).getGroupUtilizers(groupCode);
List<UserDto> dtoList = new ArrayList<>();
if (null != usernames) {
usernames.stream().forEach(i -> {
try {
dtoList.add(this.getDtoBuilder().convert(this.getUserManager().getUser(i)));
} catch (ApsSystemException e) {
logger.error("error loading {}", i, e);
}
});
}
return dtoList;
} catch (ApsSystemException ex) {
logger.error("Error loading user references for group {}", groupCode, ex);
throw new RestServerError("Error loading user references by group", ex);
}
}
Aggregations