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);
}
}
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);
}
}
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;
}
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);
}
}
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;
}
Aggregations