use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class PageModelService method removePageModel.
@Override
public void removePageModel(String code) {
try {
PageModel pageModel = this.getPageModelManager().getPageModel(code);
if (null == pageModel) {
return;
}
BeanPropertyBindingResult validationResult = this.validateDelete(pageModel);
if (validationResult.hasErrors()) {
throw new ValidationConflictException(validationResult);
}
this.getPageModelManager().deletePageModel(code);
} catch (ApsSystemException e) {
logger.error("Error in delete pagemodel {}", code, e);
throw new RestServerError("error in delete pagemodel", e);
}
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class PageModelService method getPageModels.
@Override
public PagedMetadata<PageModelDto> getPageModels(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<FieldSearchFilter>(restListReq.buildFieldSearchFilters());
filters.stream().filter(i -> i.getKey() != null).forEach(i -> i.setKey(PageModelDto.getEntityFieldName(i.getKey())));
SearcherDaoPaginatedResult<PageModel> pageModels = this.getPageModelManager().searchPageModels(filters);
List<PageModelDto> dtoList = null;
if (null != pageModels) {
dtoList = this.getDtoBuilder().convert(pageModels.getList());
}
PagedMetadata<PageModelDto> pagedMetadata = new PagedMetadata<>(restListReq, pageModels);
pagedMetadata.setBody(dtoList);
return pagedMetadata;
} catch (Throwable t) {
logger.error("error in search pageModels", t);
throw new RestServerError("error in search pageModels", t);
}
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class PageSettingsService method updatePageSettings.
@Override
public PageSettingsDto updatePageSettings(PageSettingsRequest request) {
try {
Map<String, String> params = this.createParamsMap(request);
Map<String, String> systemParams = this.getSystemParams();
params.keySet().forEach((param) -> {
systemParams.put(param, params.get(param));
});
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 page settings", e);
throw new RestServerError("Error updating page settings", e);
}
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class RoleService method addRole.
@Override
public RoleDto addRole(RoleRequest roleRequest) {
try {
Role role = this.createRole(roleRequest);
BeanPropertyBindingResult validationResult = this.validateRoleForAdd(role);
if (validationResult.hasErrors()) {
throw new ValidationConflictException(validationResult);
}
this.getRoleManager().addRole(role);
RoleDto dto = this.getDtoBuilder().toDto(role, this.getRoleManager().getPermissionsCodes());
return dto;
} catch (ApsSystemException e) {
logger.error("Error adding a role", e);
throw new RestServerError("error in add role", e);
}
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class RoleService method removeRole.
@Override
public void removeRole(String roleCode) {
try {
Role role = this.getRoleManager().getRole(roleCode);
if (null == role) {
logger.info("role {} does not exists", roleCode);
return;
}
BeanPropertyBindingResult validationResult = this.validateRoleForDelete(role);
if (validationResult.hasErrors()) {
throw new ValidationConflictException(validationResult);
}
this.getRoleManager().removeRole(role);
} catch (ApsSystemException e) {
logger.error("Error in delete role {}", roleCode, e);
throw new RestServerError("error in delete role", e);
}
}
Aggregations