Search in sources :

Example 16 with RestServerError

use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.

the class UserService method updateUser.

@Override
public UserDto updateUser(UserRequest userRequest) {
    try {
        UserDetails user = this.loadUser(userRequest.getUsername());
        UserDetails newUser = this.updateUser(user, userRequest);
        this.getUserManager().updateUser(newUser);
        return dtoBuilder.convert(newUser);
    } catch (ApsSystemException e) {
        logger.error("Error in updating user {}", userRequest.getUsername(), e);
        throw new RestServerError("Error in updating user", e);
    }
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 17 with RestServerError

use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.

the class UserService method getUsers.

@Override
public PagedMetadata<UserDto> getUsers(RestListRequest requestList) {
    try {
        // transforms the filters by overriding the key specified in the request with the correct one known by the dto
        List<FieldSearchFilter> filters = new ArrayList<FieldSearchFilter>(requestList.buildFieldSearchFilters());
        filters.stream().filter(i -> ((i.getKey() != null) && (UserDto.getEntityFieldName(i.getKey()) != null))).forEach(i -> i.setKey(UserDto.getEntityFieldName(i.getKey())));
        List<UserDetails> users = null;
        if (filters.size() > 0) {
            String text = (String) filters.get(0).getValue();
            users = this.getUserManager().searchUsers(text);
        } else {
            users = this.getUserManager().getUsers();
        }
        List<UserDto> dtoList = dtoBuilder.convert(users);
        SearcherDaoPaginatedResult<UserDetails> result = new SearcherDaoPaginatedResult<>(users.size(), users);
        PagedMetadata<UserDto> pagedMetadata = new PagedMetadata<>(requestList, result);
        pagedMetadata.setBody(dtoList);
        return pagedMetadata;
    } catch (Throwable t) {
        logger.error("error in search groups", t);
        throw new RestServerError("error in search groups", t);
    }
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) IAuthenticationProviderManager(com.agiletec.aps.system.services.user.IAuthenticationProviderManager) UserAuthoritiesRequest(org.entando.entando.web.user.model.UserAuthoritiesRequest) Logger(org.slf4j.Logger) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) UserDto(org.entando.entando.aps.system.services.user.model.UserDto) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) UserAuthorityDto(org.entando.entando.aps.system.services.user.model.UserAuthorityDto) UserRequest(org.entando.entando.web.user.model.UserRequest) UserPasswordRequest(org.entando.entando.web.user.model.UserPasswordRequest) ArrayList(java.util.ArrayList) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) List(java.util.List) User(com.agiletec.aps.system.services.user.User) RestListRequest(org.entando.entando.web.common.model.RestListRequest) RestServerError(org.entando.entando.aps.system.exception.RestServerError) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) IUserManager(com.agiletec.aps.system.services.user.IUserManager) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) IAuthorizationManager(com.agiletec.aps.system.services.authorization.IAuthorizationManager) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) UserDto(org.entando.entando.aps.system.services.user.model.UserDto) ArrayList(java.util.ArrayList) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) UserDetails(com.agiletec.aps.system.services.user.UserDetails) RestServerError(org.entando.entando.aps.system.exception.RestServerError) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Example 18 with RestServerError

use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.

the class UserSettingsService method updateUserSettings.

@Override
public UserSettingsDto updateUserSettings(UserSettingsRequest request) {
    try {
        Map<String, String> params = request.toMap();
        Map<String, String> systemParams = this.getSystemParams();
        systemParams.putAll(params);
        String xmlParams = this.getConfigManager().getConfigItem(SystemConstants.CONFIG_ITEM_PARAMS);
        String newXmlParams = SystemParamsUtils.getNewXmlParams(xmlParams, systemParams);
        this.getConfigManager().updateConfigItem(SystemConstants.CONFIG_ITEM_PARAMS, newXmlParams);
        return this.getDtoBuilder().convert(systemParams);
    } catch (Throwable e) {
        logger.error("Error updating user settings", e);
        throw new RestServerError("Error updating user settings", e);
    }
}
Also used : RestServerError(org.entando.entando.aps.system.exception.RestServerError)

Example 19 with RestServerError

use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.

the class WidgetService method getWidgets.

@SuppressWarnings("rawtypes")
@Override
public PagedMetadata<WidgetDto> getWidgets(RestListRequest restListReq) {
    try {
        // transforms the filters by overriding the key specified in the request with the correct one known by the dto
        List<FieldSearchFilter> filters = new ArrayList<>(restListReq.buildFieldSearchFilters());
        filters.stream().filter(i -> i.getKey() != null).forEach(i -> i.setKey(WidgetDto.getEntityFieldName(i.getKey())));
        SearcherDaoPaginatedResult<WidgetType> widgets = this.getWidgetManager().getWidgetTypes(filters);
        List<WidgetDto> dtoList = dtoBuilder.convert(widgets.getList());
        for (WidgetDto widgetDto : dtoList) {
            this.addFragments(widgetDto);
        }
        PagedMetadata<WidgetDto> pagedMetadata = new PagedMetadata<>(restListReq, widgets);
        pagedMetadata.setBody(dtoList);
        return pagedMetadata;
    } catch (Throwable t) {
        logger.error("error in get widgets", t);
        throw new RestServerError("error in get widgets", t);
    }
}
Also used : GuiFragment(org.entando.entando.aps.system.services.guifragment.GuiFragment) LoggerFactory(org.slf4j.LoggerFactory) RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) ApsProperties(com.agiletec.aps.util.ApsProperties) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) IPage(com.agiletec.aps.system.services.page.IPage) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) RestServerError(org.entando.entando.aps.system.exception.RestServerError) IGroupManager(com.agiletec.aps.system.services.group.IGroupManager) IPageManager(com.agiletec.aps.system.services.page.IPageManager) Service(org.springframework.stereotype.Service) IManager(com.agiletec.aps.system.common.IManager) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) GroupServiceUtilizer(org.entando.entando.aps.system.services.group.GroupServiceUtilizer) WidgetRequest(org.entando.entando.web.widget.model.WidgetRequest) Logger(org.slf4j.Logger) WidgetDto(org.entando.entando.aps.system.services.widgettype.model.WidgetDto) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) IGuiFragmentManager(org.entando.entando.aps.system.services.guifragment.IGuiFragmentManager) List(java.util.List) RestListRequest(org.entando.entando.web.common.model.RestListRequest) GroupUtilizer(com.agiletec.aps.system.services.group.GroupUtilizer) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) WidgetValidator(org.entando.entando.web.widget.validator.WidgetValidator) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ArrayList(java.util.ArrayList) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) WidgetDto(org.entando.entando.aps.system.services.widgettype.model.WidgetDto)

Example 20 with RestServerError

use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.

the class WidgetService method removeWidget.

@Override
public void removeWidget(String widgetCode) {
    try {
        WidgetType type = this.getWidgetManager().getWidgetType(widgetCode);
        BeanPropertyBindingResult validationResult = checkWidgetForDelete(type);
        if (validationResult.hasErrors()) {
            throw new ValidationGenericException(validationResult);
        }
        List<String> fragmentCodes = this.getGuiFragmentManager().getGuiFragmentCodesByWidgetType(widgetCode);
        for (String fragmentCode : fragmentCodes) {
            this.getGuiFragmentManager().deleteGuiFragment(fragmentCode);
        }
        this.getWidgetManager().deleteWidgetType(widgetCode);
    } catch (ApsSystemException e) {
        logger.error("Failed to remove widget type for request {} ", widgetCode);
        throw new RestServerError("failed to update widget type by code ", e);
    }
}
Also used : BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException)

Aggregations

RestServerError (org.entando.entando.aps.system.exception.RestServerError)65 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)45 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)28 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)25 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)13 ArrayList (java.util.ArrayList)12 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)12 IPage (com.agiletec.aps.system.services.page.IPage)10 List (java.util.List)10 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)9 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)8 LoggerFactory (org.slf4j.LoggerFactory)8 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)7 RestListRequest (org.entando.entando.web.common.model.RestListRequest)7 Logger (org.slf4j.Logger)7 ApsProperties (com.agiletec.aps.util.ApsProperties)6 Group (com.agiletec.aps.system.services.group.Group)5 GroupUtilizer (com.agiletec.aps.system.services.group.GroupUtilizer)5 IDtoBuilder (org.entando.entando.aps.system.services.IDtoBuilder)5 Category (com.agiletec.aps.system.services.category.Category)4