Search in sources :

Example 26 with RestServerError

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

the class DataObjectService method getCategoryUtilizer.

@Override
public List getCategoryUtilizer(String categoryCode) {
    try {
        DataObjectManager entityManager = (DataObjectManager) this.extractEntityManager(this.getManagerName());
        List<String> idList = ((CategoryUtilizer) entityManager).getCategoryUtilizers(categoryCode);
        return this.buildDtoList(idList, entityManager);
    } catch (ApsSystemException ex) {
        logger.error("Error loading dataobject references for category {}", categoryCode, ex);
        throw new RestServerError("Error loading dataobject references for category", ex);
    }
}
Also used : CategoryUtilizer(com.agiletec.aps.system.services.category.CategoryUtilizer) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 27 with RestServerError

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

the class DataObjectModelService method removeDataObjectModel.

@Override
public void removeDataObjectModel(Long dataModelId) {
    try {
        DataObjectModel dataObjectModel = this.getDataObjectModelManager().getDataObjectModel(dataModelId);
        if (null == dataObjectModel) {
            return;
        }
        DataModelDto dto = this.getDtoBuilder().convert(dataObjectModel);
        BeanPropertyBindingResult validationResult = this.checkDataObjectModelForDelete(dataObjectModel, dto);
        if (validationResult.hasErrors()) {
            throw new ValidationConflictException(validationResult);
        }
        this.getDataObjectModelManager().removeDataObjectModel(dataObjectModel);
    } catch (ApsSystemException e) {
        logger.error("Error in delete DataObjectModel {}", dataModelId, e);
        throw new RestServerError("error in delete DataObjectModel", e);
    }
}
Also used : DataModelDto(org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException)

Example 28 with RestServerError

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

the class DataObjectModelService method getDataObjectModels.

@Override
public PagedMetadata<DataModelDto> getDataObjectModels(RestListRequest restListReq) {
    PagedMetadata<DataModelDto> pagedMetadata = null;
    try {
        List<FieldSearchFilter> filters = new ArrayList<>(restListReq.buildFieldSearchFilters());
        // transforms the filters by overriding the key specified in the request with the correct one known by the dto
        filters.stream().filter(searchFilter -> searchFilter.getKey() != null).forEach(searchFilter -> {
            searchFilter.setKey(DataModelDto.getEntityFieldName(searchFilter.getKey()));
            if (searchFilter.getKey().equals("modelid") && null != searchFilter.getValue()) {
                String stringValue = searchFilter.getValue().toString();
                Long value = Long.parseLong(stringValue);
                searchFilter = new FieldSearchFilter("modelid", value, true);
            }
        });
        SearcherDaoPaginatedResult<DataObjectModel> models = this.getDataObjectModelManager().getDataObjectModels(filters);
        List<DataModelDto> dtoList = this.getDtoBuilder().convert(models.getList());
        pagedMetadata = new PagedMetadata<>(restListReq, models);
        pagedMetadata.setBody(dtoList);
    } catch (Throwable t) {
        logger.error("error in search data models", t);
        throw new RestServerError("error in search data models", t);
    }
    return pagedMetadata;
}
Also used : Logger(org.slf4j.Logger) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) ArrayList(java.util.ArrayList) IPage(com.agiletec.aps.system.services.page.IPage) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) List(java.util.List) 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) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) GuiFragmentValidator(org.entando.entando.web.guifragment.validator.GuiFragmentValidator) DataModelDto(org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto) Map(java.util.Map) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException) DataObjectModelRequest(org.entando.entando.web.dataobjectmodel.model.DataObjectModelRequest) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) DataModelDto(org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto) ArrayList(java.util.ArrayList) RestServerError(org.entando.entando.aps.system.exception.RestServerError) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Example 29 with RestServerError

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

the class DataObjectModelService method updateDataObjectModel.

@Override
public DataModelDto updateDataObjectModel(DataObjectModelRequest dataObjectModelRequest) {
    String code = dataObjectModelRequest.getModelId();
    try {
        Long modelId = Long.parseLong(code);
        DataObjectModel dataObjectModel = this.getDataObjectModelManager().getDataObjectModel(modelId);
        if (null == dataObjectModel) {
            throw new RestRourceNotFoundException("dataObjectModel", code);
        }
        dataObjectModel.setDataType(dataObjectModelRequest.getType());
        dataObjectModel.setDescription(dataObjectModelRequest.getDescr());
        dataObjectModel.setShape(dataObjectModelRequest.getModel());
        dataObjectModel.setStylesheet(dataObjectModelRequest.getStylesheet());
        this.getDataObjectModelManager().updateDataObjectModel(dataObjectModel);
        return this.getDtoBuilder().convert(dataObjectModel);
    } catch (RestRourceNotFoundException e) {
        throw e;
    } catch (ApsSystemException e) {
        logger.error("Error updating DataObjectModel {}", code, e);
        throw new RestServerError("error in update DataObjectModel", e);
    }
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 30 with RestServerError

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

the class AbstractEntityService method addEntityType.

protected synchronized O addEntityType(String entityManagerCode, EntityTypeDtoRequest bodyRequest, BindingResult bindingResult) {
    O response = null;
    IEntityManager entityManager = this.extractEntityManager(entityManagerCode);
    try {
        IDtoBuilder<I, O> builder = this.getEntityTypeFullDtoBuilder(entityManager);
        if (null != entityManager.getEntityPrototype(bodyRequest.getCode())) {
            this.addError(EntityTypeValidator.ERRCODE_ENTITY_TYPE_ALREADY_EXISTS, bindingResult, new String[] { bodyRequest.getCode() }, "entityType.exists");
        }
        I entityPrototype = this.createEntityType(entityManager, bodyRequest, bindingResult);
        if (bindingResult.hasErrors()) {
            return response;
        } else {
            ((IEntityTypesConfigurer) entityManager).addEntityPrototype(entityPrototype);
            response = builder.convert(entityPrototype);
        }
    } catch (Throwable e) {
        logger.error("Error adding entity type", e);
        throw new RestServerError("error add entity type", e);
    }
    return response;
}
Also used : IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) RestServerError(org.entando.entando.aps.system.exception.RestServerError) IEntityTypesConfigurer(com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)

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