Search in sources :

Example 41 with RestServerError

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

the class AbstractListViewerWidgetValidator method validate.

@Override
public BeanPropertyBindingResult validate(WidgetConfigurationRequest widget, IPage page) {
    BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(widget, widget.getClass().getSimpleName());
    try {
        logger.debug("validating widget {} for page {}", widget.getCode(), page.getCode());
        WidgetValidatorCmsHelper.validateTitle(widget, getLangManager(), bindingResult);
        WidgetValidatorCmsHelper.validateLink(widget, getLangManager(), getPageManager(), bindingResult);
    } catch (Throwable e) {
        logger.error("error in validate wiget {} in page {}", widget.getCode(), page.getCode());
        throw new RestServerError("error in widget config validation", e);
    }
    return bindingResult;
}
Also used : BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError)

Example 42 with RestServerError

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

the class DataObjectModelService method addDataObjectModel.

@Override
public DataModelDto addDataObjectModel(DataObjectModelRequest dataObjectModelRequest) {
    try {
        DataObjectModel dataModel = this.createDataObjectModel(dataObjectModelRequest);
        this.getDataObjectModelManager().addDataObjectModel(dataModel);
        return this.getDtoBuilder().convert(dataModel);
    } catch (ApsSystemException e) {
        logger.error("Error adding DataObjectModel", e);
        throw new RestServerError("error add DataObjectModel", e);
    }
}
Also used : RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 43 with RestServerError

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

the class AbstractEntityService method deleteEntityType.

protected void deleteEntityType(String entityManagerCode, String entityTypeCode) {
    IEntityManager entityManager = this.extractEntityManager(entityManagerCode);
    try {
        IApsEntity entityType = entityManager.getEntityPrototype(entityTypeCode);
        if (null == entityType) {
            return;
        }
        List<String> ids = entityManager.searchId(entityTypeCode, null);
        if (null != ids && ids.size() > 0) {
            BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(entityType, "entityType");
            bindingResult.reject(EntityTypeValidator.ERRCODE_ENTITY_TYPE_REFERENCES, new Object[] { entityTypeCode }, "entityType.cannot.delete.references");
            throw new ValidationConflictException(bindingResult);
        }
        ((IEntityTypesConfigurer) entityManager).removeEntityPrototype(entityTypeCode);
    } catch (ApsSystemException e) {
        logger.error("Error in delete entityType {}", entityTypeCode, e);
        throw new RestServerError("error in delete entityType", e);
    }
}
Also used : BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) RestServerError(org.entando.entando.aps.system.exception.RestServerError) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) IEntityTypesConfigurer(com.agiletec.aps.system.common.entity.IEntityTypesConfigurer) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException)

Example 44 with RestServerError

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

the class AbstractEntityService method filterObjects.

protected boolean filterObjects(Object bean, Filter[] filters, Map<String, String> mapping) {
    try {
        if (null == filters) {
            return true;
        }
        Map<String, Object> properties = BeanUtils.describe(bean);
        for (Filter filter : filters) {
            String fieldName = this.getFieldName(filter.getAttribute(), mapping);
            String value = (null != properties.get(fieldName)) ? properties.get(fieldName).toString() : null;
            if (null == value) {
                continue;
            }
            if (!value.toLowerCase().contains(filter.getValue().toLowerCase())) {
                return false;
            }
        }
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        logger.error("error filtering bean " + bean.getClass().getName(), e);
        throw new RestServerError("error filtering bean " + bean.getClass().getName(), e);
    }
    return true;
}
Also used : Filter(org.entando.entando.web.common.model.Filter) RestServerError(org.entando.entando.aps.system.exception.RestServerError) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 45 with RestServerError

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

the class GroupService method updateGroup.

@Override
public GroupDto updateGroup(String groupCode, String descr) {
    Group group = this.getGroupManager().getGroup(groupCode);
    if (null == group) {
        throw new RestRourceNotFoundException(GroupValidator.ERRCODE_GROUP_NOT_FOUND, "group", groupCode);
    }
    group.setDescription(descr);
    try {
        this.getGroupManager().updateGroup(group);
        return this.getDtoBuilder().convert(group);
    } catch (ApsSystemException e) {
        logger.error("Error updating group {}", groupCode, e);
        throw new RestServerError("error in update group", e);
    }
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) Group(com.agiletec.aps.system.services.group.Group) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

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