use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class PageService method deleteWidgetConfiguration.
@Override
public void deleteWidgetConfiguration(String pageCode, int frameId) {
try {
IPage page = this.loadPage(pageCode, STATUS_DRAFT);
if (null == page) {
throw new RestRourceNotFoundException(ERRCODE_PAGE_NOT_FOUND, "page", pageCode);
}
if (frameId > page.getWidgets().length) {
throw new RestRourceNotFoundException(ERRCODE_FRAME_INVALID, "frame", String.valueOf(frameId));
}
this.pageManager.removeWidget(pageCode, frameId);
} catch (ApsSystemException e) {
logger.error("Error in delete widget configuration for page {} and frame {}", pageCode, frameId, e);
throw new RestServerError("error in delete widget configuration", e);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class PageService method updatePage.
@Override
public PageDto updatePage(String pageCode, PageRequest pageRequest) {
IPage oldPage = this.getPageManager().getDraftPage(pageCode);
if (null == oldPage) {
throw new RestRourceNotFoundException(null, "page", pageCode);
}
this.validateRequest(pageRequest);
try {
IPage newPage = this.updatePage(oldPage, pageRequest);
this.getPageManager().updatePage(newPage);
return this.getDtoBuilder().convert(newPage);
} catch (ApsSystemException e) {
logger.error("Error updating page {}", pageCode, e);
throw new RestServerError("error in update page", e);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException 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 com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class PageModelService method getReferencingObjects.
@SuppressWarnings("unchecked")
public Map<String, List<Object>> getReferencingObjects(PageModel pageModel) throws ApsSystemException {
Map<String, List<Object>> references = new HashMap<String, List<Object>>();
try {
String[] defNames = applicationContext.getBeanNamesForType(PageModelUtilizer.class);
for (String beanName : defNames) {
Object service = null;
try {
service = applicationContext.getBean(beanName);
} catch (Throwable t) {
logger.error("error in hasReferencingObjects", t);
service = null;
}
if (service != null) {
PageModelUtilizer pageModelUtilizer = (PageModelUtilizer) service;
List<Object> utilizers = pageModelUtilizer.getPageModelUtilizers(pageModel.getCode());
if (utilizers != null && !utilizers.isEmpty()) {
references.put(pageModelUtilizer.getName() + "Utilizers", utilizers);
}
}
}
} catch (Throwable t) {
throw new ApsSystemException("Error on getReferencingObjects methods", t);
}
return references;
}
use of com.agiletec.aps.system.exception.ApsSystemException 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);
}
}
Aggregations